Function tc(s)
tc = s
i = 0
Do While tc = o
tc = s.Offset(-1 - i, 0)
i = i + 1
Loop
End Function

Function R_calcu(size As String, amount, wrap, perr, perm)
'space to 0
If perr = 0 Or perm = 0 Then
    R_calcu = 0
ElseIf Left(wrap, 1) <> "R" Then
    R_calcu = 0
ElseIf width(size) < 585 Then
    perr = 2 * perr
    R_calcu = amount / perm * perr
    
Else
    R_calcu = amount / perm * perr
End If


'0 to ''
If R_calcu = 0 Then R_calcu = ""

End Function

